package com.kcs.fxmargin.dao;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;

import com.kcs.fxmargin.model.MRole;

public class RoleDao {

	public List<MRole> getRole(Connection conn) throws Exception{
		
		PreparedStatement pstm 	= null;
		ResultSet rs 			= null;
		StringBuffer sql 		= new StringBuffer();
		List<MRole> roleList	= new ArrayList<MRole>();
		MRole role				= null;
		
		try{
			sql.append(" select id, code, name from m_role where active_status = 'A' ");
			
			pstm = conn.prepareStatement(sql.toString());
			rs   = pstm.executeQuery();
			
			while(rs.next()){
				role = new MRole();
				role.setId(rs.getString("id"));
				role.setCode(rs.getString("code"));
				role.setName(rs.getString("name"));
				
				roleList.add(role);
			}
			
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			if(pstm != null) pstm.close();
			if(rs != null) rs.close();
		}
		
		
		
		
		return roleList;
	}
}
